﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Small.Test;

namespace SmallProject.Controllers
{
    public class AutoCompleteController : Controller
    {
      
        /// <summary>
        /// 自动完成控件服务端,仅可以返回label,value,icon,desc格式
        /// </summary>
        /// <param name="no">NoSysAutocomplete数据库的一个索引列,根据索引行执行SQL语句返回结果</param>
        /// <param name="term"></param>
        /// <returns></returns>
        [HttpGet]
        public ActionResult Index(string no, string term) 
        {
            List<Student> students = new List<Student>();
            students.Add(new Student { StudentName = "A", Age = 1 });
            students.Add(new Student { StudentName = "B", Age = 1 });
            students.Add(new Student { StudentName = "C", Age = 1 });
            students.Add(new Student { StudentName = "D", Age = 1 });
            students.Add(new Student { StudentName = "E", Age = 1 });
            students.Add(new Student { StudentName = "F", Age = 1 });





            var data = students.Select(p => new { label = p.StudentName, value = p.StudentName });


            return Json(data, JsonRequestBehavior.AllowGet);
        }

    }
}
